/**
 * 
 */
package org.cuatrovinetos.parking;


import java.util.Hashtable;

/**
 * Represent list of Cars
 * @author David
 *
 */
public class Parking extends Hashtable<String,Car> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5910590936005051605L;

	/**
	 * Insert a Car
	 * @param mycar
	 * @return
	 */
	public String insertCar(Car myCar){
		if (!this.containsKey(myCar.getName())){
			this.put(myCar.getName(), myCar);
			return "OK";
		}
		return "Not OK"; 
	}
	
	/**
	 * Create and insert Car
	 * @param name
	 * @param branch
	 * @return
	 */
	public String insertCar(String name, String branch){
		Car myCar= new Car(name,branch);
		return insertCar(myCar);
	}
	
	/**
	 * Remove Car
	 * @param myCar
	 * @return
	 */
	public String removeCar(Car myCar){
		if (this.containsKey(myCar.getName())){
			this.remove(myCar.getName());
			return "OK";
		}
		return "Not Ok";
	}
	
	/**
	 * Other Form of remove a car
	 * @param name
	 * @return
	 */
	public String removeCar(String name){
		Car myCar = new Car(name);
		return removeCar(myCar);
		
	}
	
}
